<?php 
session_start();
create_image(); 
exit(); 

function create_image() 
{ 

    $md5_hash = md5(rand(0,999)); // ma hoa cac ky tu bao gom so va chu cai
    $security_code = substr($md5_hash, 15, 5); //dung substr lay 5 ky tu tu chuoi ma 
    $_SESSION["security_code"] = $security_code;
     $image = imagecreatefrompng('captcha11.png');
    $black = ImageColorAllocate($image, 0, 0, 0); 
    ImageString($image, 5, 35, 6, $security_code, $black); 
    header("Content-Type: image/jpeg"); //tra noi dung tro ve dang hinh
    ImageJpeg($image); 
    ImageDestroy($image); 
} 
?>